<!DOCTYPE html>
<html>

<head>
	<title>消费记录</title>
	<include file='public/head'>
		<style>
			table th,
			table td {
				text-align: center;
			}

			.ml-10 {
				margin-left: 10px;
			}
		</style>
</head>

<body>

	<div class="wrap js-check-wrap">

		<ul class="nav nav-tabs">
			<php> $currentTab = 3;</php>
			<include file="public/nav" />
		</ul>

		<form class="well form-inline margin-top-20">
			<select name="batOpera" class="form-control" style="display:inline;width:120px;">
				<option value="">批量操作</option>
				<option value="batDelete" data-href="{:cmf_plugin_url('SmsAccount://sms_account_consume/batDelete')}">批量删除
				</option>
			</select>
			<select type="text" name="condition1" class="form-control">
				<option value="1" <?php if($search['condition1']==1){echo 'selected';}  ?>>用户id</option>
				<option value="1" <?php if($search['condition1']==2){echo 'selected';}  ?>>账号id</option>
				<option value="1" <?php if($search['condition1']==3){echo 'selected';}  ?>>手机号</option>
			</select>
			<input type="text" class="form-control" name="keyword" style="width:200px;" value="{$search.keyword}"
				placeholder="输入关键词" />
			时间:
			<input type="text" class="js-bootstrap-date js-bootstrap-datetime form-control" autocomplete="off"
				name="start_time" value="{$search['start_time']|default=''}" placeholder="开始时间" style="width:120px">
			--
			<input type="text" autocomplete="off" class="js-bootstrap-date form-control" name="end_time"
				value="{$search['end_time']|default=''}" placeholder="结束时间" style="width:120px">


			<input type="submit" class="btn btn-primary" value="搜索" />
		</form>
		<form>
			<table class="table table-bordered table-hover" zIndex="100">
				<thead>
					<tr class="theader">
						<th style="text-align:center;">
							<input input="" class="bat_ck_all" type="checkbox">
						</th>
						<th>ID</th>
						<th>账号ID</th>
						<th>用户ID</th>
						<th>内容</th>
						<th>接收人</th>
						<th>ip</th>
						<th>添加时间</th>
					</tr>
				</thead>
				<tbody>
					<volist name="data" id="vo">
						<tr>
							<td>
								<input class="bat_ck" type="checkbox" value="{$vo.id}">
							</td>
							<td>{$vo.id}</td>
							<td>{$vo.accountid}</td>
							<td>{$vo.uid}</td>
							<td>{$vo.msg}</td>
							<td>{$vo.mobile}</td>
							<td>{$vo.ip}</td>
							<td>{:date('Y-m-d H:i:s',$vo.create_time)}</td>
						</tr>
					</volist>
				</tbody>
			</table>

			<div class="pagination">{$page|default=''}</div>

		</form>
	</div>





	<include file='public/scripts'>
		<script src="__STATIC__/js/layer/layer.js"></script>
		<script src="__STATIC__/js/custom/custom.js"></script>

		<script>

			//全选/取消
			$('.bat_ck_all').on('click', function () {
				$('.bat_ck').prop('checked', $('.bat_ck_all').prop('checked'));
			});
			/**
			 * 获取选中的项的值
			 * @return {[type]} [description]
			 */
			function getCheckedItem() {
				var items = $('.bat_ck:checked');
				var result = [];
				$.each(items, function () {
					result.push($(this).val());
				});
				return result;
			}
			/**
			* 批量操作
			*/
			$("select[name=batOpera]").on('change', function () {
				var href = $(this).find('option:selected').data('href');
				var isSubmit = false;
				var id = getCheckedItem();

				if (id.length == 0) {
					$($('select[name=batOpera]').find('option')[0]).prop('selected', true);
					layer.msg('还没有选中项', function () { });
					return false;
				}

				if ($(this).find('option:selected').val() == 'batDelete') {
					layer.confirm('确定要批量删除选中的项吗？', { title: '批量删除确认', btn: ['确认', '取消'] }, function () {
						isSubmit = true;
						sumitOpera(href, { id: id });
					});
				}
				if ($(this).find('option:selected').val() == 'allTurnOn') {
					layer.confirm('确定要批量启用选中的项吗？', { title: '批量启用确认', btn: ['确认', '取消'] }, function () {
						isSubmit = true;
						sumitOpera(href, { id: id });
					});
				}
				if ($(this).find('option:selected').val() == 'allTurnOff') {
					layer.confirm('确定要批量禁用选中的项吗？', { title: '批量禁用确认', btn: ['确认', '取消'] }, function () {
						isSubmit = true;
						sumitOpera(href, { id: id });
					});
				}
				if (!isSubmit) {
					$($('select[name=batOpera]').find('option')[0]).prop('selected', true);
				}
			});
			/**
			* 提交操作
			* @param  {[type]} href [description]
			* @param  {[type]} data [description]
			* @return {[type]}      [description]
			*/
			function sumitOpera(href, data) {
				$.post(href, data, function (data) {
					data = JSON.parse(data);
					var icon = (data.status == 'error') ? 5 : 1;
					layer.msg(data.message, { icon: icon });
					setTimeout(function () {
						window.location.reload();
					}, 1000);
				});
			}

		</script>




</body>

</html>